<?php
class Core_Model_DbTable_TrackingInvoice extends Zend_Db_Table_Abstract {
    protected $_name = 'tracking_invoice';
   
    public function getInvoiceNumber($user_id) {
        $data = array (
            'created_time' => time(),
            'user_id' => $user_id
        );
        $id = $this->insert($data);
        $str_len = strlen($id);
        $result = "EPAC-";
        if ($str_len < 7) {
            $prefix = str_repeat(0, 7 - $str_len);
            $result .= $prefix . $id;
        } else {
            $result .= $id;
        }
        return $result;
    }
}
?>
